import requests

from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles

app = FastAPI()
templates = Jinja2Templates(directory="templates")
app.mount("/static", StaticFiles(directory="static"), name="static")


@app.get('/')
async def name(request: Request):
    return templates.TemplateResponse('home.html', {'request': request, 'name': 'Hello, Encore!'})


@app.get('/cell_automaton')
async def cell_automaton(request: Request):
    mask = request.get('127.0.0.1:8081')
    print(f"mask is {mask}")
    context = {
        'request': request,
        'cell_automaton_epoch': "./static/images/test.jpg"
    }
    return templates.TemplateResponse('cell_automaton.html', context)